package problem122;

//122. 买卖股票的最佳时机 II
//https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/?envType=study-plan-v2&envId=top-interview-150

class Solution {
    public int maxProfit(int[] prices) {
        int n = prices.length;
        int ret = 0;
        for(int i = 1; i<n; i++) {
            if(prices[i] > prices[i-1]) {
                ret += prices[i] - prices[i-1];
            }
        }
        return ret;
    }
}